<template>
    <div>
        <el-input type="text" v-model="context"  placeholder="请输入内容" @keyup.enter.native="add"/>
    </div>
</template>
<script>
import {nanoid} from'nanoid'
export default {
    data() {
        return {
            context:""
        }
    },
    methods:{
        add(){
           if(this.context.trim()) {
                const todoObj = {
                id: nanoid(),
                context: this.context,
                done: false
            }
            this.$emit('receive',todoObj)
            this.context = ""
           }
        }
    }
}
</script>